package com.teamone.etl.apimanager.entity;

import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.teamone.etl.apimanager.valid.AddGroup;
import com.teamone.etl.apimanager.valid.UpdateGroup;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Transient;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * 接口计费表(ApiCharge)表实体类
 *
 * @author makejava
 * @since 2021-01-20 18:32:04
 */
@EqualsAndHashCode(callSuper = true)
@SuppressWarnings("serial")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApiCharge extends Model<ApiCharge> {
    /**序号
     *
     */
    @NotNull(message = "接口计费方式id不能为空",groups = {UpdateGroup.class})
    private Integer id;
    /**计费类型，1按次数计费，2按天数计费
     *
     */
    @NotNull(message = "计费类型不能为空",groups = {AddGroup.class, UpdateGroup.class})
    private Integer chargeType;

    /**源接口id
     *
     */
    private Integer apiSourceId;

    /**接口类型id
     *
     */
    private Integer apiTypeId;

    /**次数
     *
     */
    private Integer count;

    /**天数
     *
     */
    private Integer days;

    /**价格
     *
     */
    @NotNull(message = "价格阈值不能为空",groups = {AddGroup.class, UpdateGroup.class})
    private Integer price;

    /**创建时间
     *
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-M-d",timezone = "GMT+8")
    private Date createTime;

    /**创建人
     *
     */
    private String createBy;

    /**修改时间
     *
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-M-d",timezone = "GMT+8")
    private Date updateTime;

    /**修改人
     *
     */
    private String updateBy;

    /**
     * 逻辑删除
     */
    private Boolean isDelete;

    /**
     * 接口名称
     */
    @Transient
    private String apiSourceName;

    /**
     * 获取主键值
     *
     * @return 主键值
     */
    @Override
    protected Serializable pkVal() {
        return this.id;
    }
}